package com.cet6.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cet6.entity.Word;
import com.cet6.mapper.WordMapper;
import com.cet6.service.WordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WordServiceImpl extends ServiceImpl<WordMapper, Word> implements WordService {
    
    @Autowired
    private WordMapper wordMapper;
    
    @Override
    public IPage<Word> getWordPage(Integer page, Integer size, String keyword) {
        Page<Word> pageParam = new Page<>(page, size);
        return wordMapper.selectWordPage(pageParam, keyword);
    }
    
    @Override
    public Word getWordById(Long id) {
        QueryWrapper<Word> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id).eq("deleted", 0);
        return this.getOne(queryWrapper);
    }
}
